package com.fy.service.impl;

import com.fy.mapper.UserMapper;
import com.fy.pojo.User;
import com.fy.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

@Service
@Transactional
public class UserServiceImpl implements UserService {
    @Autowired
    UserMapper userMapper;
    @Override
    @Transactional(readOnly = true)
    public User getUser(String username) {
        return userMapper.getUser(username);
    }

    @Override
    @Transactional(propagation = Propagation.REQUIRES_NEW)
    public int add(User user) {
        return userMapper.add(user);
    }
}
